package com.gupaoedu.pattern.prototype.shallow;

import com.gupaoedu.pattern.prototype.Course;
import com.gupaoedu.pattern.prototype.Prototype;

import java.util.List;

/**
 * 2019/5/12
 * created by chenpp
 */
public class Student implements Prototype {
    private String studentName;
    private List<Course> courses;//学生的课程表

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public List<Course> getCourses() {
        return courses;
    }

    public void setCourses(List<Course> courses) {
        this.courses = courses;
    }
    /**
     * 浅克隆,对于引用类型只是copy引用的地址
     * */
    public Object clone() {
        Student stu = new Student();
        stu.setStudentName(this.studentName);
        stu.setCourses(this.getCourses());
        return stu;
    }
}
